//
//  AppDelegate.m
//  MemoryTravel
//
//  Created by dllo on 15/12/21.
//  Copyright © 2015年 fcx. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//    sleep(1);//启动时间

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    NSString *isFirstStart = [[NSUserDefaults standardUserDefaults] objectForKey:@"isFirstStart"];
    if ([isFirstStart isEqualToString:@"NO"]) {
        //不是第一次启动程序,不再加载引导页,直接进入应用程序
        [self FirstLauncherController];
    }else{
        //第一次启动程序,加载引导页
        LauncherViewController *launchVC = [[LauncherViewController alloc] init];
        self.window.rootViewController = launchVC;
        [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"isFirstStart"];
    }
    return YES;
}

- (void)FirstLauncherController{
#pragma mark -- 首页(旅途)
    TravlesViewController *travelVC = [[TravlesViewController alloc]init];
    UINavigationController *travelNaVC = [[UINavigationController alloc]initWithRootViewController:travelVC];
    travelNaVC.navigationBar.barTintColor = [UIColor cyanColor];//导航背景颜色
    //取消渲染
    UIImage *travelFrontImage = [UIImage imageNamed:@"TabBarIconFeaturedNormal.png"];
    travelFrontImage  = [travelFrontImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *travelBackImage = [UIImage imageNamed:@"TabBarIconFeatured.png"];
    travelBackImage  = [travelBackImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    travelNaVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"旅途" image:travelFrontImage selectedImage:travelBackImage];

#pragma mark -- 第二栏(世界)
    WorldViewController *worldVC = [[WorldViewController alloc]init];
    UINavigationController *worldNaVC = [[UINavigationController alloc]initWithRootViewController:worldVC];
    worldNaVC.navigationBar.barTintColor = [UIColor cyanColor];//导航背景颜色
    //取消渲染
    UIImage *worldFrontImage = [UIImage imageNamed:@"TabBarIconDestinationNormal.png"];
    worldFrontImage  = [worldFrontImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *worldBackImage = [UIImage imageNamed:@"TabBarIconDestination.png"];
    worldBackImage  = [worldBackImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    worldNaVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"世界" image:worldFrontImage selectedImage:worldBackImage];

#pragma mark -- 第三栏(经历)
    ExperienceViewController *experienceVC = [[ExperienceViewController alloc]init];
    UINavigationController *experienceNaVC = [[UINavigationController alloc]initWithRootViewController:experienceVC];
    experienceNaVC.navigationBar.barTintColor = [UIColor cyanColor];//导航背景颜色
    //取消渲染
    UIImage *experienceFrontImage = [UIImage imageNamed:@"TabBarIconToolboxNormal.png"];
    experienceFrontImage  = [experienceFrontImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *experienceBackImage = [UIImage imageNamed:@"TabBarIconToolbox.png"];
    experienceBackImage  = [experienceBackImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    experienceNaVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"经历" image:experienceFrontImage selectedImage:experienceBackImage];

#pragma mark -- 第四栏(音频)
    VideoMusuicViewController *videomusicVC = [[VideoMusuicViewController alloc]init];
    UINavigationController *videomusicNaVC = [[UINavigationController alloc]initWithRootViewController:videomusicVC];
    videomusicNaVC.navigationBar.barTintColor = [UIColor cyanColor];//导航背景颜色
    //取消渲染
    UIImage *videomusicFrontImage = [UIImage imageNamed:@"TabBarIconOfflineNormal.png"];
    videomusicFrontImage  = [videomusicFrontImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *videomusicBackImage = [UIImage imageNamed:@"TabBarIconOffline.png"];
    videomusicBackImage  = [videomusicBackImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    videomusicNaVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"音频" image:videomusicFrontImage selectedImage:videomusicBackImage];

#pragma mark -- 第五栏(个人)
    MineViewController *mineVC = [[MineViewController alloc]init];
    UINavigationController *mineNaVC = [[UINavigationController alloc]initWithRootViewController:mineVC];
    mineNaVC.navigationBar.barTintColor = [UIColor cyanColor];//导航背景颜色
    //取消渲染
    UIImage *mineFrontImage = [UIImage imageNamed:@"TabBarIconMyNormal.png"];
    mineFrontImage  = [mineFrontImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *mineBackImage = [UIImage imageNamed:@"TabBarIconMy.png"];
    mineBackImage  = [mineBackImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    mineNaVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:mineFrontImage selectedImage:mineBackImage];

    //设置tabBar上面的内容
    UITabBarController *tabBarC = [[UITabBarController alloc]init];
    //指定tabbarcontroller的子视图控制器
    tabBarC.viewControllers = [NSArray arrayWithObjects:travelNaVC, worldNaVC, experienceNaVC, videomusicNaVC, mineNaVC, nil];
    //指定为window根视图
    self.window.rootViewController = tabBarC;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
